/*******************************************************************************
 * Copyright (c) 2008 Smart Mai(smardio@gmail.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Smart Mai(smardio@gmail.com) - initial API and implementation
 ******************************************************************************/
package com.smartdio.company.model;

import java.util.Vector;

/**
 * @author smart
 * 
 */
public class Department {

	public String name;
	public long id;
	public String description;
	public String address;
	public String phone1;
	public String phone2;

	public Department parent;

	public Company company;

	private Vector<Department> departments;
	private Vector<Person> personnels;
	
	

	/**
	 * 
	 */
	public Department(Company company) {
		this.company = company;
		company.addDepartment(this);
		departments =new Vector<Department>();
		personnels = new Vector<Person>();
	}

	public Department(Company company, boolean demoData) {
		this(company);
		if (demoData)
			createDemoData();
	}

	public Department(Department dep) {
		this.parent = dep;
		this.company = dep.company;
		dep.addDepartment(this);
		departments =new Vector<Department>();
		personnels = new Vector<Person>();
	}

	public Department(Department dep, boolean demoData) {
		this(dep);
		if (demoData)
			createDemoData();
	}

	private void createDemoData() {
		name = "A Department";
		description = "Description about this Department.";
		address = "Department location";
		phone1 = "0123456";
		phone2 = "0123466";
	}

	public void addPersonnel(Person p) {
		personnels.add(p);
	}

	public void removePersonnel(Person p) {
		personnels.remove(p);
	}

	public Vector<Person> getPersonnels() {
		return personnels;
	}


	public void addDepartment(Department dep) {
		departments.add(dep);
	}
	
	public void removeDepartment(Department dep){
		departments.remove(dep);
	}

	public Vector<Department> getDepartments() {
		return departments;
	}
	

	
}
